set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/third_party/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(VCPKG_DEFAULT_TRIPLET "x64-linux")

project(kys)
cmake_minimum_required(VERSION 3.12)

set(CMAKE_VERBOSE_MAKEFILE on)
set(CMAKE_CXX_COMPILER $ENV{CXX})   
set(CMAKE_CXX_FLAGS "-std=c++14 -pthread -DUSE_SDL_MIXER_AUDIO")
# set(CMAKE_CXX_FLAGS "-O3 -std=c++14 -pthread -DNDEBUG -DUSE_SDL_MIXER_AUDIO")
set(CMAKE_INCLUDE_CURRENT_DIR ON)

find_package(SDL2 CONFIG REQUIRED)
find_package(sdl2-image CONFIG REQUIRED)
find_package(sdl2-mixer CONFIG REQUIRED)
find_package(sdl2-ttf CONFIG REQUIRED)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
find_package(Lua REQUIRED)


include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/third_party/common ${CMAKE_SOURCE_DIR}/others ${CMAKE_SOURCE_DIR}/local/include ${CMAKE_SOURCE_DIR}/third_party/nb)
link_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/../lib)

add_subdirectory(third_party/opencc)

file(GLOB SRC_LIST
    ${CMAKE_SOURCE_DIR}/src/*.cpp   
    ${CMAKE_SOURCE_DIR}/third_party/common/convert.cpp
    ${CMAKE_SOURCE_DIR}/third_party/common/File.cpp
    ${CMAKE_SOURCE_DIR}/others/Hanz2Piny.cpp
    ${CMAKE_SOURCE_DIR}/others/zip.c)

set(LINK_LIBRARIES
    SDL2::SDL2 
    SDL2::SDL2main
    SDL2::SDL2-static
    SDL2::SDL2_ttf
    SDL2::SDL2_image
    SDL2::SDL2_mixer
    unofficial::sqlite3::sqlite3
    # lua5.3
    libopencc
    fmt
    ${LUA_LIBRARIES}
)
if (APPLE)
    set(LINK_LIBRARIES ${LINK_LIBRARIES} iconv)
endif ()

add_executable(kys ${SRC_LIST})
target_link_libraries(kys ${LINK_LIBRARIES})
target_include_directories(kys PRIVATE ${LUA_INCLUDE_DIR})
